﻿<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>System Management</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.3/css/bootstrap.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #18bc9c;
            --danger-color: #e74c3c;
        }

        body {
            background-color: #f8f9fa;
            min-height: 100vh;
            padding: 2rem;
        }

        #main {
            max-width: 1200px;
            margin: 0 auto;
        }

        .management-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            padding: 2rem;
            margin-bottom: 2rem;
        }

        h1 {
            color: var(--primary-color);
            border-bottom: 3px solid var(--secondary-color);
            padding-bottom: 0.5rem;
            margin-bottom: 1.5rem;
        }

        .table-responsive {
            border-radius: 8px;
            overflow: hidden;
        }

        .table thead {
            background: var(--primary-color);
            color: white;
        }

        .table-hover tbody tr:hover {
            background-color: rgba(24, 188, 156, 0.05);
        }

        .action-buttons {
            display: flex;
            gap: 0.5rem;
        }

        .btn-custom {
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            transition: all 0.3s ease;
        }

        .btn-update {
            background-color: var(--secondary-color);
            color: white;
            border: 1px solid var(--secondary-color);
        }

        .btn-delete {
            background-color: var(--danger-color);
            color: white;
            border: 1px solid var(--danger-color);
        }

        .nav-links {
            display: flex;
            gap: 1rem;
            margin: 2rem 0;
        }

        .nav-link {
            padding: 0.8rem 1.5rem;
            border-radius: 6px;
            text-decoration: none;
            transition: transform 0.2s;
        }

        .nav-link-primary {
            background-color: var(--secondary-color);
            color: white;
        }

        .nav-link-secondary {
            background-color: var(--primary-color);
            color: white;
        }

        .nav-link-danger {
            background-color: var(--danger-color);
            color: white;
        }

        .nav-link:hover {
            transform: translateY(-2px);
            color: white;
        }

        @media (max-width: 768px) {
            body {
                padding: 1rem;
            }

            .table-responsive {
                overflow-x: auto;
            }

            .action-buttons {
                flex-direction: column;
            }
        }
    </style>
</head>
<body>
<div id="main">
    <div class="management-card">
        <div id="network_info">
            <h1>🌐 Network Services</h1>
            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead>
                    <tr>
                        <th>Service Name</th>
                        <th>Host</th>
                        <th>Port</th>
                        <th>Actions</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="service : ${networkServices}">
                        <td th:text="${service.name}"></td>
                        <td th:text="${service.domain}"></td>
                        <td th:text="${service.port}"></td>
                        <td>
                            <div class="action-buttons">
                                <a class="btn btn-custom btn-update"
                                   th:href="@{'/info/update?service_name='+${service.name}}">
                                    ✏️ Update
                                </a>
                                <a class="btn btn-custom btn-delete"
                                   th:href="@{'/info/delete?service_name='+${service.name}}">
                                    🗑️ Delete
                                </a>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>

            <div class="nav-links">
                <a href="/info/update" class="nav-link nav-link-primary">➕ Add New Service</a>
                <a href="/" class="nav-link nav-link-secondary">🔙 Back to Chatroom</a>
                <a href="/?logout=true" class="nav-link nav-link-danger">🚪 Logout</a>
            </div>
        </div>
    </div>

    <div class="management-card">
        <div id="message_details">
            <h1>✉️ Message History</h1>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>Sender Location</th>
                        <th>Time Sent</th>
                        <th>Message Content</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="message : ${message_details}">
                        <td th:text="${message.sender}"></td>
                        <td th:text="${message.time}"></td>
                        <td th:text="${message.content}"></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>